﻿using System;
using RpcHelper;
using RpcModel;
using Wedonek.RpcStore.Service.DAL;
using Wedonek.RpcStore.Service.Interface;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Service.Collect
{
    internal class AutoTaskCollect : BasicCollect<AutoTaskDAL>, IAutoTaskCollect
    {
        public Guid Add(AutoTask task)
        {
            return this.BasicDAL.Add(task);
        }
        public void Drop(AutoTaskList task)
        {
            this.BasicDAL.Drop(task.Id);
        }
        public AutoTaskList Get(Guid id)
        {
            AutoTaskList task = this.BasicDAL.Get(id);
            if (task == null)
            {
                throw new ErrorException("rpc.task.not.find");
            }
            return task;

        }
        public void Set(AutoTaskList task, AutoTaskSetParam param)
        {
            if (param.IsEquals(task))
            {
                return;
            }
            this.BasicDAL.SetAutoTask(task.Id, param);
        }
        public AutoTaskDatum[] Query(QueryTaskParam query, IBasicPage paging, out long count)
        {
            return this.BasicDAL.QueryTask(query, paging, out count);
        }

        public void SetIsEnable(AutoTaskList task, bool isEnable)
        {
            if (task.IsEnable == isEnable)
            {
                return;
            }
            this.BasicDAL.SetIsEnable(task.Id, isEnable);
        }
    }
}
